<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>My Test</title>
<link type="text/css" rel="stylesheet" href="css/index.css"/>
<link type="text/css" rel="stylesheet" href="css/main.css"/>
</head>
<body>
	租房信息
	
	<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
	
	<table width="100%" border="0" cellpadding="0" cellspacing="0" class="main_table">
		<tr class="main_head">
			<th><input type="checkbox" name="sltAll" id="sltAll" onclick="sltAllRooms()"/></th>
			<th>序号</th>
			<th>房间号</th>
			<th>房间状态</th>
			<th>房间描述</th>
			<th>房间价格</th>
			<th>操作</th>
		</tr>
		<c:choose>
			<c:when test="${not empty roomList}">
				<c:forEach items="${roomList}" var="room" varStatus="vs">
				<tr class="main_info">
				<td><input type="checkbox" name="roomIds" id="roomIds${room.roomId }" value="${room.roomId }"/></td>
				<td>${vs.index+1}</td>
				<td>${room.roomnum }</td>
				<td>${room.room_state }</td>
				<td>${room.room_desc }</td>
				<td>${room.room_price }</td>
				<td><a href="javascript:editRoom(${room.roomId });">修改</a> | <a href="javascript:delRoom(${room.roomId });">删除</a></td>
				</tr>
				</c:forEach>
			</c:when>
			<c:otherwise>
				<tr class="main_info">
					<td colspan="7">没有相关数据</td>
				</tr>
			</c:otherwise>
		</c:choose>
	</table>
	
	<div class="page_and_btn">
		<div>
			<a href="javascript:addroom();" class="myBtn"><em>新增</em></a>
		</div>
	</div>
	
	<script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
	<script type="text/javascript" src="js/lhgdialog/lhgdialog.min.js?t=self&s=areo_blue"></script>
	<script type="text/javascript">
	
		function addroom(){
			var dg = new $.dialog({
				title:'新增房源',
				id:'room_new',
				width:330,
				height:220,
				iconTitle:false,
				cover:true,
				maxBtn:false,
				xButton:true,
				resize:false,
				page:'room/add.html'
				});
			dg.ShowDialog();
		}
		
		function editRoom(roomId){
			var dg = new $.dialog({
				title:'修改房源',
				id:'room_edit',
				width:330,
				height:220,
				iconTitle:false,
				cover:true,
				maxBtn:false,
				xButton:true,
				resize:false,
				page:'room/edit.html?roomId='+roomId
				});
    		dg.ShowDialog();
		}
		
		function delRoom(roomId){
			var url = "room/del.html?roomId="+roomId;
			$.get(url,function(data){
				document.location.reload();
			});
		}
		
		function sltAllRooms(){
			if($("#sltAll").attr("checked")){
				$("input[name='roomIds']").attr("checked",true);
			}else{
				$("input[name='roomIds']").attr("checked",false);
			}
		}
		</script>
	
</body>
</html>